00001 // Emacs Mode Line: -*- Mode:c++;-*- 00002 // ------------------------------------------------------------- 00003 /* 00004 * Copyright (c) 2013 Battelle Memorial Institute 00005 * Licensed under modified BSD License. A copy of this license can be found 00006 * in the LICENSE file in the top level directory of this distribution. 00007 */ 00008 // ------------------------------------------------------------- 00009 // ------------------------------------------------------------- 00010 /** 00011 * @file implementation_visitable.hpp 00012 * @author William A. Perkins 00013 * @date 2014-10-22 09:03:08 d3g096 00014 * 00015 * @brief Declaration of the abstract ImplementationVisitable class. 00016 * 00017 */ 00018 // ------------------------------------------------------------- 00019 // ------------------------------------------------------------- 00020 // Created October 21, 2014 by William A. Perkins 00021 // Last Change: 2014-10-21 14:41:29 d3g096 00022 // ------------------------------------------------------------- 00023 00024 00025 #ifndef _implementation_visitable_hpp_ 00026 #define _implementation_visitable_hpp_ 00027 00028 namespace gridpack { 00029 namespace math { 00030 00031 class ImplementationVisitor; 00032 class ConstImplementationVisitor; 00033 00034 // ------------------------------------------------------------- 00035 // class ImplementationVisitable 00036 // ------------------------------------------------------------- 00037 /// Interface for classes that accept ImplementationVisitor's 00038 /** 00039 * Classes that can be visited by an ImplementationVisitor can 00040 * subclass from this. It is still necessary to provide 00041 * specialization to recognize specific classes in the 00042 * ImplementationVisitor class. 00043 * 00044 */ 00045 class ImplementationVisitable { 00046 protected: 00047 00048 /// Protected copy constructor to avoid unwanted copies. 00049 ImplementationVisitable(const ImplementationVisitable& old); 00050 00051 public: 00052 00053 /// Default constructor. 00054 ImplementationVisitable(void) 00055 {} 00056 00057 /// Destructor 00058 ~ImplementationVisitable(void) 00059 {} 00060 00061 /// Allow visits by implemetation visitor 00062 void accept(ImplementationVisitor& visitor) 00063 { 00064 this->p_accept(visitor); 00065 } 00066 00067 /// Allow visits by const implemetation visitor 00068 void accept(ConstImplementationVisitor& visitor) const 00069 { 00070 this->p_accept(visitor); 00071 } 00072 00073 protected: 00074 00075 /// Allow visits by implementation visitors 00076 virtual void p_accept(ImplementationVisitor& visitor) = 0; 00077 00078 /// Allow visits by implementation visitors 00079 virtual void p_accept(ConstImplementationVisitor& visitor) const = 0; 00080 00081 }; 00082 00083 } // namespace math 00084 } // namespace gridpack 00085 #endif